import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-04-15
 * Time: 21:49
 */
public class test_2 {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger atomicInteger= new AtomicInteger(5);
        Thread thread1=new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                atomicInteger.getAndIncrement();
            }
        });
        Thread thread2=new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                atomicInteger.getAndIncrement();
            }
        });
        thread1.start();
        thread2.start();
        thread1.join();
        thread2.join();
        System.out.println(atomicInteger);
    }
}
